package avicit.bdp.dgs.metadata.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import java.util.Objects;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.commons.lang3.StringUtils;

/**
 * @author mayi 元模型属性
 */
@ApiModel(value = "MetadataModelAttributeDTO", description = "元模型属性")
@Table(name = "bdp_dgs_metadata_model_attribute")
public class MetadataModelAttributeDTO extends BaseDTO {

  public static final int TYPE_TECH = 1;
  public static final int TYPE_BUS = 2;

  /** 主键 */
  @Id
  @LogField
  @ApiModelProperty(value = "主键", name = "id")
  @FieldRemark(column = "id", field = "id", name = "主键")
  private String id;

  /** 元模型ID */
  @LogField
  @ApiModelProperty(value = "元模型ID", name = "metadataModelId")
  @FieldRemark(column = "metadata_model_id", field = "metadataModelId", name = "元模型ID")
  private String metadataModelId;

  /** 是否有效 */
  @LogField
  @ApiModelProperty(value = "是否有效", name = "validFlag")
  @FieldRemark(column = "valid_flag", field = "validFlag", name = "是否有效")
  private Integer validFlag;

  /** 属性编码 */
  @LogField
  @ApiModelProperty(value = "属性编码", name = "attributeCode")
  @FieldRemark(column = "attribute_code", field = "attributeCode", name = "属性编码")
  private String attributeCode;

  /** 属性名称 */
  @LogField
  @ApiModelProperty(value = "属性名称", name = "attributeName")
  @FieldRemark(column = "attribute_name", field = "attributeName", name = "属性名称")
  private String attributeName;

  /** 属性分类[1技术属性，2内置业务属性，3自定义内置属性] */
  @LogField
  @ApiModelProperty(value = "属性分类[1技术属性，2内置业务属性，3自定义业务属性]", name = "type")
  @FieldRemark(column = "type", field = "type", name = "属性分类[1技术属性，2内置业务属性，3自定义内置属性]")
  private Integer type;

  /** 属性类型[0文本，1下拉框] */
  @LogField
  @ApiModelProperty(value = "属性类型[0文本，1下拉框]", name = "attributeType")
  @FieldRemark(column = "attribute_type", field = "attributeType", name = "属性类型[0文本，1下拉框]")
  private Integer attributeType;

  /** 允许多选 */
  @LogField
  @ApiModelProperty(value = "允许多选", name = "multiple")
  @FieldRemark(column = "multiple", field = "multiple", name = "允许多选")
  private Integer multiple;

  /** 属性描述 */
  @LogField
  @ApiModelProperty(value = "属性描述", name = "description")
  @FieldRemark(column = "description", field = "description", name = "属性描述")
  private String description;

  /** 允许长度 */
  @LogField
  @ApiModelProperty(value = "允许长度", name = "length")
  @FieldRemark(column = "length", field = "length", name = "允许长度")
  private Integer length;

  /**
   * 下拉选项
   *
   * @see avicit.bdp.dgs.metadata.dto.OptionAttribute
   */
  @LogField
  @ApiModelProperty(value = "下拉选项", name = "optionAttribute")
  @FieldRemark(column = "option_attribute", field = "optionAttribute", name = "下拉选项")
  private String optionAttribute;

  /** 属性值 */
  @LogField
  @ApiModelProperty(value = "属性值", name = "value")
  @FieldRemark(column = "value", field = "value", name = "属性值")
  private String value;

  /** 是否引用数据字典 */
  @LogField
  @ApiModelProperty(value = "是否引用数据字典")
  @FieldRemark(column = "quote_lookup_table", field = "quoteLookupTable", name = "是否引用数据字典")
  private Integer quoteLookupTable;

  /** 引用数据字典主键 */
  @LogField
  @ApiModelProperty(value = "引用数据字典主键", name = "lookupTableId")
  @FieldRemark(column = "lookup_table_id", field = "lookupTableId", name = "引用数据字典主键")
  private String lookupTableId;

  @Transient
  @ApiModelProperty(value = "引用数据字典名称", name = "lookupTableName")
  private String lookupTableName;

  @Transient
  @ApiModelProperty(value = "下拉选项", name = "optionAttributeList")
  private List<OptionAttribute> optionAttributeList;

  @ApiModelProperty(value = "显示值")
  @Transient
  private String displayValue;

  @Override
  public String getLogFormName() {
    if (StringUtils.isEmpty(super.logFormName)) {
      return "元数据模块";
    } else {
      return super.logFormName;
    }
  }

  @Override
  public String getLogTitle() {
    if (StringUtils.isEmpty(super.logTitle)) {
      return "元模型属性";
    } else {
      return super.logTitle;
    }
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getMetadataModelId() {
    return metadataModelId;
  }

  public void setMetadataModelId(String metadataModelId) {
    this.metadataModelId = metadataModelId;
  }

  public Integer getValidFlag() {
    return validFlag;
  }

  public void setValidFlag(Integer validFlag) {
    this.validFlag = validFlag;
  }

  public String getAttributeCode() {
    return attributeCode;
  }

  public void setAttributeCode(String attributeCode) {
    this.attributeCode = attributeCode;
  }

  public String getAttributeName() {
    return attributeName;
  }

  public void setAttributeName(String attributeName) {
    this.attributeName = attributeName;
  }

  public Integer getType() {
    return type;
  }

  public void setType(Integer type) {
    this.type = type;
  }

  public Integer getAttributeType() {
    return attributeType;
  }

  public void setAttributeType(Integer attributeType) {
    this.attributeType = attributeType;
  }

  public Integer getMultiple() {
    return multiple;
  }

  public void setMultiple(Integer multiple) {
    this.multiple = multiple;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public Integer getLength() {
    return length;
  }

  public void setLength(Integer length) {
    this.length = length;
  }

  public String getOptionAttribute() {
    return optionAttribute;
  }

  public void setOptionAttribute(String optionAttribute) {
    this.optionAttribute = optionAttribute;
  }

  public String getValue() {
    return value;
  }

  public void setValue(String value) {
    this.value = value;
  }

  public List<OptionAttribute> getOptionAttributeList() {
    return optionAttributeList;
  }

  public void setOptionAttributeList(List<OptionAttribute> optionAttributeList) {
    this.optionAttributeList = optionAttributeList;
  }

  public Integer getQuoteLookupTable() {
    return quoteLookupTable;
  }

  public void setQuoteLookupTable(Integer quoteLookupTable) {
    this.quoteLookupTable = quoteLookupTable;
  }

  public String getLookupTableId() {
    return lookupTableId;
  }

  public void setLookupTableId(String lookupTableId) {
    this.lookupTableId = lookupTableId;
  }

  public String getLookupTableName() {
    return lookupTableName;
  }

  public void setLookupTableName(String lookupTableName) {
    this.lookupTableName = lookupTableName;
  }

  public String getDisplayValue() {
    return displayValue;
  }

  public void setDisplayValue(String displayValue) {
    this.displayValue = displayValue;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    MetadataModelAttributeDTO that = (MetadataModelAttributeDTO) o;
    return Objects.equals(getId(), that.getId())
        && Objects.equals(getMetadataModelId(), that.getMetadataModelId())
        && Objects.equals(getValidFlag(), that.getValidFlag())
        && Objects.equals(getAttributeCode(), that.getAttributeCode())
        && Objects.equals(getAttributeName(), that.getAttributeName())
        && Objects.equals(getType(), that.getType())
        && Objects.equals(getAttributeType(), that.getAttributeType())
        && Objects.equals(getMultiple(), that.getMultiple())
        && Objects.equals(getDescription(), that.getDescription())
        && Objects.equals(getLength(), that.getLength())
        && Objects.equals(getOptionAttribute(), that.getOptionAttribute())
        && Objects.equals(getValue(), that.getValue())
        && Objects.equals(getQuoteLookupTable(), that.getQuoteLookupTable())
        && Objects.equals(getLookupTableId(), that.getLookupTableId());
  }

  @Override
  public int hashCode() {
    return Objects.hash(
        getId(),
        getMetadataModelId(),
        getValidFlag(),
        getAttributeCode(),
        getAttributeName(),
        getType(),
        getAttributeType(),
        getMultiple(),
        getDescription(),
        getLength(),
        getOptionAttribute(),
        getValue(),
        getQuoteLookupTable(),
        getLookupTableId());
  }

  @Override
  public String toString() {
    return "MetadataModelAttributeDTO{"
        + "id='"
        + id
        + '\''
        + ", metadataModelId='"
        + metadataModelId
        + '\''
        + ", validFlag="
        + validFlag
        + ", attributeCode='"
        + attributeCode
        + '\''
        + ", attributeName='"
        + attributeName
        + '\''
        + ", type="
        + type
        + ", attributeType="
        + attributeType
        + ", multiple="
        + multiple
        + ", description='"
        + description
        + '\''
        + ", length="
        + length
        + ", optionAttribute='"
        + optionAttribute
        + '\''
        + ", value='"
        + value
        + '\''
        + ", quoteLookupTable="
        + quoteLookupTable
        + ", lookupTableId='"
        + lookupTableId
        + '\''
        + ", optionAttributeList="
        + optionAttributeList
        + '}';
  }
}
